<?php
/**
 * 
 * @author szm
 *
 */

class Dialogue_model extends CI_Model {
    
    
    public function __construct(){
        parent::__construct();
        $this->load->database();
    }
    public  function test(){
    
        return "testing";
    }
    public function getDialogues($lessonIds=0){
        if(empty($lessonIds)){
            return false;
        }
        if(!is_array($lessonIds)){
            $lessonIds=array($lessonIds);
        }
        $lessonIds=implode(",",$lessonIds);
        $sql="select * from dialogue_sentences as ds
			left join sample_sentences  as ss
        	on ds.sample_sentence_id  = ss.sample_sentence_id 
			where ss.lesson_id in ($lessonIds)";
	     try{
            $dbSource=$this->db->query($sql);
            $resultArr=$dbSource->result_array();
            return $resultArr;
	     }catch(Exception $e){
            return $sql;
         }

    }
    public function listAllDialogues(){

    }
    
    public function getDialogue(){

    }
    
    public function saveDialogue(){


    }
    
    public function removeDialogue(){

    }
}

